package cn.appsys.interceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class Loginterceptor extends HandlerInterceptorAdapter{
	
	//统计每个动作（controller的方法）的执行时间，在控制台输出
	long start;
	@Override
	public boolean preHandle(HttpServletRequest request,
				HttpServletResponse response, Object handler) throws Exception {
		
		start = System.currentTimeMillis();
		System.out.println("进入请求："+request.getRequestURI());
		return true;
	}
	@Override
	public void postHandle(HttpServletRequest request,
				HttpServletResponse response, Object handler,ModelAndView mv) throws Exception {
		
		long end = System.currentTimeMillis();
		System.out.println("请求完成，使用时间："+(end-start));
		
	}
}
